package com.aaa.three.service.impl;

import com.aaa.three.mapper.NewsTakedownMapper;
import com.aaa.three.pojo.domain.Newst;
import com.aaa.three.pojo.query.NewsTakedown;
import com.aaa.three.result.AjaxResult;
import com.aaa.three.service.NewsTakedownService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class NewsTakedownServiceImpl implements NewsTakedownService {

    @Autowired
    private NewsTakedownMapper newsTakedownMapper;

//    @Override
//    public AjaxResult listTakedown(NewsTakedown newsTakedown ) {
//        List<Newst> news = newsTakedownMapper.listTakedown(newsTakedown);
//        Long aLong = newsTakedownMapper.queryNewsTakedownTotal(newsTakedown);
//        HashMap<Object, Object> map = new HashMap<>();
//        map.put("currentData", news);
//        map.put("totalCount", aLong);
//        return AjaxResult.success(map);
//    }

    @Override
    public AjaxResult newsOn(Integer id) {
        int i = newsTakedownMapper.newsOn(id);
        if (i > 0) {
            return AjaxResult.success();
        }
        return AjaxResult.fail("上架失败");
    }

    @Override
    public AjaxResult newsOut(Integer id) {
        int i = newsTakedownMapper.newsOut(id);
        if (i > 0) {
            return AjaxResult.success();
        }
        return AjaxResult.fail("下架失败");
    }

    @Override
    public AjaxResult newsTop(Integer id) {
        int i = newsTakedownMapper.newsTop(id);
        if (i > 0) {
            return AjaxResult.success();
        }
        return AjaxResult.fail("置顶失败");
    }
}
